package com.jt.sys.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jt.common.exception.ServiceException;
import com.jt.common.vo.PageObject;
import com.jt.sys.dao.SysLogDao;
import com.jt.sys.entity.SysLog;
import com.jt.sys.service.SysLogService;
@Service
@Transactional
public class SysLogServiceImpl implements SysLogService {
	@Autowired
	private SysLogDao sysLogDao;
	@Override
	public PageObject<SysLog> findPageObjects(Integer pageCurrent, String username) {
		if(pageCurrent==null||pageCurrent<1){
			throw new IllegalArgumentException("页码值不正确");
		}
		int rows = sysLogDao.getRowCount(username);
		if (rows==0){
			throw new ServiceException("没有记录");
		}
		int pageSize=4;
		int startIndex= (pageCurrent-1)*pageSize;
		List<SysLog> list=sysLogDao.findPageObjects(startIndex, pageSize, username);
		PageObject<SysLog> pageObj = new PageObject<>();
		pageObj.setPageCurrent(pageCurrent);
		pageObj.setPageSize(pageSize);
		pageObj.setRowCount(rows);
		pageObj.setRecords(list);
		return pageObj;
	}
	
}
